# 编译器配置
CC = gcc
CFLAGS = -Wall -O2

# 自动获取源文件
SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)
TARGET = Server

# 跨平台配置
ifeq ($(OS),Windows_NT)
    # Windows命令需通过cmd执行，错误输出重定向到NUL设备
    RM = cmd /C del /Q /F 2>NUL
    TARGET := $(TARGET).exe
else
    RM = rm -f
endif

$(TARGET): $(OBJ)
	$(CC) $(CFLAGS) $^ -o $@

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

.PHONY: clean
clean:
	$(RM) $(TARGET) $(OBJ)
